#include("_user_msg_layout.html")
#@user_msg_layout("sms")

#define layout_script()
<script src="#(CPATH)/static/components/selectize/selectize.min.js"></script>
<script>

    var $select = $('.article-tags').selectize({
        plugins: ['remove_button'],
        delimiter: ',',
        persist: false,
        addPrecedence: true,
        create: true,
        render: {
            option_create: function (data, escape) {
                return '<div class="create" style="padding-left: 5px"> 选择标签：<strong style="color: #DD1144">' + escape(data.input) + '</strong> &hellip; </div>';
            }
        }
    });

    $(".newTag").each(function () {
        $(this).on('click', function () {
            $select[0].selectize.createItem($(this).text());
        })
    });

</script>
#end

#define layout_css()
<link href="#(CPATH)/static/components/selectize/css/selectize.css" rel="stylesheet">
#end

#define detail()

<form class=" autoAjaxSubmit" autocomplete="off" action="#(CPATH)/admin/user/doSendSms" data-ok-message="短信发送成功，可能会有延迟，请稍后查收。">
    <div class="card-body">

        <div class="form-group row">
            <label class="col-sm-2 col-form-label">用户标签</label>
            <div class="col-sm-8">
                <select class="article-tags" multiple="multiple" name="userTag">
                    #for(tag : userTags)
                    <option value="#(tag.title ??)" selected>#(tag.title ??)</option>
                    #end
                </select>
                <p class="text-muted">短信将会发送给该标签下的所有用户，多个标签请用 “回车键” 或英文逗号（,）隔开。</p>
                <div class="tags">
                    #for(tag : hotTags)
                    <a href="javascript:;" class="newTag">#(tag.title)</a>
                    #end
                </div>
            </div>
        </div>


        <div class="form-group row">
            <label class="col-sm-2 col-form-label">抄送给</label>
            <div class="col-sm-8">
                <textarea rows="2" name="cc" class="form-control" ></textarea>
                <p class="text-muted">可以手动在这里输入手机号，这里的手机也都会收到短信。</p>
            </div>
        </div>



        <div class="form-group row">
            <label class="col-sm-2 col-form-label">通知短信模板</label>
            <div class="col-sm-8">
                <textarea rows="2" class="form-control" placeholder="..." name="sms_template"></textarea>
                <p class="text-muted"> 请先在 <a href="#(CPATH)/admin/setting/connection">[通信]</a> 开启短信功能，这里填写阿里云或腾讯云的短信模板ID。
                </p>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 col-form-label">短信签名</label>
            <div class="col-sm-8">
                <input type="input" class="form-control" placeholder="只有部分服务商需要短信签名"
                       name="sms_sign" >
                <p class="text-muted"> 请填写阿里云或腾讯云的短信签名。</p>
            </div>
        </div>



    </div>
    <!-- /.card-body -->
    <div class="card-footer">
        <div class="offset-sm-2 col-sm-10 submit-block">
            <div class="card-submit">
                <button type="submit" class="btn btn-primary">发送</button>
            </div>
        </div>
    </div>
</form>
    <!-- /.card-footer -->
#end

